package com.qitmiaojie.mapper;

import com.qitmiaojie.controller.utils.Result;
import com.qitmiaojie.pojo.Malfunction;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @Entity com.qitmiaojie.pojo.Malfunction
 */
public interface MalfunctionMapper extends BaseMapper<Malfunction> {
    @Insert("INSERT INTO malfunction VALUES(NULL,#{name},#{address},#{floor},#{phone},#{desc}, #{date},#{userid}, #{status},'没有评分',NULL) ")
    boolean insertMalfuncation(Malfunction malfunction);
    @Select("select * from malfunction where userid = #{id} ORDER BY DATE desc")
    List<Malfunction> selectAllById(Integer id);
    @Delete("delete from malfunction where id = #{id}")
    void removeMalfuncationById(Integer id);

    @Update("UPDATE malfunction SET advice = #{advice},VALUE = #{value} WHERE id = #{id};")
    void evaluate(Integer id, String value, String advice);
    @Select("select * from malfunction where id = #{id}")
    Malfunction selectMalfunctionById(Integer id);

    Integer selectAllCount(Map<String, Object> map);

    List<Malfunction> selectAll(Map<String, Object> map);
    @Update("update malfunction set status = #{status} where id = #{id}")
    boolean updateStatusById(Integer id, Integer status);
}




